
<template>
  <el-table :data="tableData" style="width: 100%" :header-cell-style="{ background: '#f2f2f2', color: '#333', fontWeight: 600, }" @cell-click="cellClickOnge">
   <!-- :formatter="formatDateC"这个是饿了么提供的方法 就是转换时间格式 -->
    <el-table-column label="资源名称" align="left" show-overflow-tooltip>
      <template slot-scope="scope">
        <img :src="scope.row.img" style="width: 80px;height: 64px;margin-right: 10px;">
        {{ scope.row.name == null ? '--' : scope.row.name }}
      </template>
    </el-table-column>
    <el-table-column label="学科" align="center">
      <template slot-scope="scope">
        {{ scope.row.subject == "" ? '--' : scope.row.subject }}
      </template>
    </el-table-column>
    <el-table-column label="分类" align="center">
      <template slot-scope="scope">
        {{ scope.row.fname == "" ? '--' : scope.row.fname }}
      </template>
    </el-table-column>
    <el-table-column label="年级" align="center">
      <template slot-scope="scope">
        {{ scope.row.clas == "" ? '--' : scope.row.clas }}
      </template>
    </el-table-column>
    <el-table-column label="下载次数" align="center">
      <template slot-scope="scope">
        {{ scope.row.sci == null ? '--' : scope.row.sci }}
      </template>
    </el-table-column>
    <el-table-column label="平均学习时长" align="center">
      <template slot-scope="scope">
        {{ scope.row.pinshi == null ? '--' : scope.row.pinshi }}
      </template>
    </el-table-column>
    <el-table-column label="创建时间" align="center">
      <template slot-scope="scope">
        {{ scope.row.createDate == null ? '--' : scope.row.createDate }}
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { timestampToTime } from '../../utils/util';   //引入转换时间方法
export default {
  props: {
    tableData: {
      type: Array,
      default: null,
    },
  },
  methods: {
    // 格式化时间格式
    // formatDateC(row) {
    //   const createDate = timestampToTime(row.createDate)
    //   return createDate;
    // }
    cellClickOnge(row) {
      this.$emit('cellClickOnge', row);
    }
  }
};

</script>
